added Feb 2001 SDK
[windows-sources.git] / shared source / sscli20 / jscript / engine / jsclosureproperty.cs
blob2aa48b29f2366ac8f8b6d0e9f28c687ee80b7a70
1 // ==++==
2 //
3 //
4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
5 //
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
10 //
11 // You must not remove this notice, or any other, from this software.
12 //
13 //
14 // ==--==
16 namespace Microsoft.JScript {
18 using System;
19 using System.Reflection;
20 using System.Globalization;
22 internal class JSClosureProperty : JSWrappedProperty{
23 private MethodInfo getMeth;
24 private MethodInfo setMeth;
26 internal JSClosureProperty(PropertyInfo property, MethodInfo getMeth, MethodInfo setMeth)
27 :base(property, null){
28 this.getMeth = getMeth;
29 this.setMeth = setMeth;
32 public override Object GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) {
33 if (this.getMeth == null)
34 throw new MissingMethodException();
35 return this.getMeth.Invoke(obj, invokeAttr, binder, index, culture);
38 public override MethodInfo GetGetMethod(bool nonPublic){
39 if (nonPublic || (this.getMeth != null && this.getMeth.IsPublic))
40 return this.getMeth;
41 else
42 return null;
45 public override MethodInfo GetSetMethod(bool nonPublic){
46 if (nonPublic || (this.setMeth != null && this.setMeth.IsPublic))
47 return this.setMeth;
48 else
49 return null;
52 public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) {
53 if (this.setMeth == null)
54 throw new MissingMethodException();
55 int n = index == null ? 0 : index.Length;
56 Object[] pars = new Object[n+1];
57 pars[0] = value;
58 if (n > 0)
59 ArrayObject.Copy(index, 0, pars, 1, n);
60 this.setMeth.Invoke(obj, invokeAttr, binder, pars, culture);